import moment from 'moment'

export const dateFormat = (date, format) => {
  if (!date) return date
  format = format || 'YYYY-MM-DD HH:mm:ss'
  return moment(date).format(format)
}

export const dateIsBefore = (date1, date2) => moment(date1).isBefore(date2)

export const dateIsAfter = (date1, date2) => moment(date1).isAfter(date2)

export const dateIsSame = (date1, date2) => moment(date1).isSame(date2)

export const dateYearsGap = (date1, date2) => moment(date1).diff(date2, 'years')